import { createRouter, createWebHashHistory } from 'vue-router';
export default createRouter({
  history: createWebHashHistory(),
  routes: [
    {
    // 主页
      redirect: '/home',
      path: '/',
      name: '首页',
      component: () => import('@/views/home/index.vue'),
      children: [
        {
          path: '/home',
          name: '首页',
          component: () => import('@/views/home/homepage/index.vue'),
        },
        // 分类
        {
          path: '/category/:id',
          name: '分类',
          component: () => import('@/views/home/categorypage/index.vue'),
        },
        // 二级分类
        {
          path: '/category/sub/:id',
          name: '二级分类',
          component: () => import('@/views/home/subcategorypage/index.vue'),
        },
        // 购物车
        {
          path: '/cart',
          name: '购物车',
          component: () => import('@/views/home/cartpage/index.vue'),
        },
        // 物品详情页
        {
          path: '/product/:id',
          name: '详情页',
          component: () => import('@/views/home/product/index.vue'),
        },
      ],
    },
    {
    // 登录
      path: '/login',
      component: () => import('@/views/login/index.vue'),
    },
  ],
});
